chore: add execProcess wrapper and refactor poetryUtils (Fixes #1239)#1240
Open
karthiknadig wants to merge 4 commits intomainfrom
Open
chore: add execProcess wrapper and refactor poetryUtils (Fixes #1239)#1240karthiknadig wants to merge 4 commits intomainfrom
karthiknadig wants to merge 4 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves testability and consistency of child-process usage by introducing an execProcess() wrapper in src/common/childProcess.apis.ts and refactoring Poetry utilities to use it, while also fixing Poetry 1.x version parsing.
Changes:
- Added
execProcess()wrapper aroundcp.exec()insrc/common/childProcess.apis.ts. - Refactored
src/managers/poetry/poetryUtils.tsto useexecProcess()instead of a directchild_processimport + promisify. - Added unit tests covering
getPoetryVersion()parsing and demonstrating stubbingexecProcess().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/common/childProcess.apis.ts | Adds execProcess() wrapper to centralize cp.exec usage and improve mockability. |
| src/managers/poetry/poetryUtils.ts | Switches Poetry exec calls to the wrapper and adjusts version-regex parsing for Poetry 1.x output. |
| src/test/managers/poetry/poetryUtils.unit.test.ts | Adds unit tests that stub childProcess.apis.execProcess() and validate version parsing. |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/common/childProcess.apis.ts:23
- The comment states "with PYTHONUTF8 as default", but the spread order
{ PYTHONUTF8: '1', ...process.env, ...options?.env }means PYTHONUTF8='1' has the LOWEST priority and will be overridden by both process.env and options.env if they contain PYTHONUTF8. While this is the correct JavaScript behavior for setting defaults, the comment could be clearer.
Consider rephrasing to: "Sets PYTHONUTF8='1' as a fallback default (can be overridden by process.env or options.env)"
// Always inherit process.env, then merge options.env overrides, with PYTHONUTF8 as default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds an
execProcesswrapper tochildProcess.apis.tsand refactorspoetryUtils.tsto use it, improving testability.Changes:
execProcessfunction tosrc/common/childProcess.apis.tsas a wrapper aroundcp.execwithPYTHONUTF8handlingsrc/managers/poetry/poetryUtils.tsto useexecProcessinstead of directchild_processimportgetPoetryVersionthat didn't handle the space in Poetry 1.x version output formatpoetryUtils.unit.test.tsdemonstrating the mocking pattern forexecProcessTesting:
Note: This is a partial implementation of #1239. The acceptance criteria for auditing
fsimports is deferred to a future PR to keep this change focused.For #1239